package cn.hchaojie.camp.day03;

import java.util.Arrays;

public class DemoMethodDefinition {
	public static void main(String[] args) {
		printDiamond(2);
		int result = 1;
		printDiamond(5);
		
		
		int[] numbers = {23, 32, 55, 77, 43};
		int[] reversedNumbers = reverse(numbers);
		System.out.println(Arrays.toString(numbers));
		System.out.println(Arrays.toString(reversedNumbers));
	}
	
	// 求两个数面的最大值
	public static int max(int a, int b) {
		return (b > a) ? b : a;
	}
	
	// 打印菱形, 指定大小
	public static void printDiamond(int size) {
		for (int y = size; y >= -size; y--) {
			for (int x = -size; x <= size; x++) {
				if (Math.abs(x) + Math.abs(y) <= size) {
					System.out.print(" *");
				} else {
					System.out.print("  ");
				}
			}
			
			System.out.println();
		}
	}
	
	// 数组倒置，原来的数组不动，返回新的数组
	public static int[] reverse(int[] array) {
		int[] result = new int[array.length];
		
		// 倒置处理
//		for (int i = array.length - 1; i >= 0; i--) {
//			result[i] = array[array.length - i - 1];
//		}
		for (int i = 0; i < array.length; i++) {
			result[i] = array[array.length - i - 1];
		}
		
		return result;
	}
	
	// 判断两个整数是否有公约数
	public static boolean hasCommonDivisor(int a, int b) {
		//
		return false;
	}
	
	// [0, 1, 0, 0, 0]		能不能种n盆花
	public static boolean canPlaceFlower(int n) {
		return false;
	}
}
